
AR	?= ar r
GCC 	?= gcc
GXX	?= g++
RANLIB	?= ranlib
RM	?= rm -f
MV	?= mv

CXXFLAGS += -Wno-write-strings -Wall -Werror
CXXFLAGS += -m64 -fvisibility=hidden
LDFLAGS += -m64 -L/usr/local/ctp 
TARGET = testTraderApi
INCLUDES = -I/usr/local/ctp
LIBS = -lthosttraderapi
SOURCES = \
	main.cpp \
	TraderSpi.cpp

ifeq ($(release), 1) 
	EXEDIR = release
	CXXFLAGS += -O2 -DNDEBUG
else
	EXEDIR = debug
	CXXFLAGS += -g -O0 -DDEBUG -D_DEBUG
endif

OBJECTS = main.o TraderSpi.o

.PHONY: default
default: $(EXEDIR)/$(TARGET)

%.o: ./%.cpp
	$(GXX) -c $(INCLUDES) $(CXXFLAGS) $< -o $@

$(EXEDIR)/$(TARGET):$(OBJECTS)
	mkdir -p $(dir $@)
	$(GCC) $(OBJECTS) $(LDFLAGS) -Wall $(LIBS) -o $@

clean:
	rm -f $(OBJECTS)
	rm -rf $(EXEDIR)

